<%template _header%>
<%if {infloat}!=1%>
<div class="wrap cl pageinfo">
	<div id="nav">
		<%if {usergroupinfo.allowsearch}>0%>
			<%template _quicksearch%>
		<%/if%>
		<a href="{config.forumurl}">{config.forumtitle}</a> &raquo; <strong>用户注册</strong>
	</div>
</div>
<%/if%>
<%if {agree}=="" && {infloat}!=1%>
	<%if page_err==0%>
		<%if {config.rules}==1%>
        <div class="wrap cl">
	        <div class="blr">
		        <h3 class="flb"><em>用户注册协议</em></h3>
		        <form id="form1" name="form1" method="post" action="">
		        <div class="c cl floatwrap">
			        {config.rulestxt}
		        </div>
		        <p class="fsb pns cl">
			        <input name="agree" type="hidden" value="true" />
			        <button disabled="disabled" type="submit" id="btnagree" class="pn pnc"><span>同意</span></button>
			        <button name="cancel" id="cancel" type="button" onClick="javascript:location.replace('index.aspx')" class="pn"><span>不同意</span></button>	  
			        <script type="text/javascript">
			        var secs = 5;
			        var wait = secs * 1000;
			        $("btnagree").innerHTML = "<span>同 意(" + secs + ")</span>";
			        $("btnagree").disabled = true;
			        for(i = 1; i <= secs; i++) {
				        window.setTimeout("update(" + i + ")", i * 1000);
			        }
			        window.setTimeout("timer()", wait);
			        function update(num, value) {
				        if(num == (wait/1000)) {
						        $("btnagree").innerHTML = "<span>同 意</span>";
				        } else {
						        printnr = (wait / 1000) - num;
						        $("btnagree").innerHTML = "<span>同 意(" + printnr + ")</span>";
				        }
			        }
			        function timer() {
				        $("btnagree").disabled = false;
				        $("btnagree").innerHTML = "<span>同 意</span>";
			        }
			        </script>
		        </p>
		        </form>
	        </div>
        </div>
		<%csharp%>
		/*
		<script type="text/javascript">
		location.replace('register.aspx?agree=yes')
		</script>
		*/
		<%/csharp%>
		<%/if%>
	<%else%>
		<%template _errmsgbox%>
	<%/if%>
<%else%>

<%if {createuser}==""%>
    <%if {page_err}==0%>
	    <%if {infloat}!=1%>
	    <div class="wrap cl">
		    <div class="blr" id="floatlayout_register">
	    <%/if%>
	    <%if {config.rules}==1%>
		    <div id="bbrule" style="display:none">
			    <%if {infloat}==1%>
					<h3 class="flb" id="fctrl_register" style="cursor: move;"><em id="returnregmessage" fwin="register">网站服务条款</em><span><a title="关闭" onclick="hideWindow('register')" class="flbc" onclick="hideWindow('register')" title="关闭">关闭</a></span></h3>
			    <%/if%>
			    <div class="c cl floatwrap">
				    {config.rulestxt}
			    </div>
			    <p class="fsb pns cl">
				    <button type="submit" id="btnagree" class="pn pnc"  onclick="javascript:$('agree').checked=true;$('bbrule').style.display='none';$('bbreg').style.display=''"><span>同意</span></button>
				    <button name="cancel" id="cancel"  onClick="hideWindow('register')" class="pn"><span>不同意</span></button>
			    </p>
		    </div>
	    <%/if%>
	    <%if {infloat}==1%>
	    <div id="bbreg">
	        <h3 class="flb"><em id="returnregmessage">注册</em><span><a href="javascript:;" class="flbc" onclick="hideWindow('register')" title="关闭">关闭</a></span></h3>
	        <div id="succeedmessage" class="c cl" style="display:none"></div>
	            <form id="form2" name="form2" method="post" onsubmit=" <%if {config.rules}==1%>if(!checkagreed()) return false;<%/if%>$('form2').action='{rooturl}register.aspx?infloat=1&createuser=1&';ajaxpost('form2', 'returnregmessage', 'returnregmessage', 'onerror');return false;" action="{rooturl}register.aspx?infloat=1&createuser=1&">
	    <%else%>
            <h3 class="flb"><em id="returnregmessage"></em></h3>
            <div id="succeedmessage" class="c cl" style="display:none"></div>
            <form id="form1" name="form1" method="post" action="?createuser=1">
	    <%/if%>
	        <div class="c cl">
		        <div style="overflow:hidden;overflow-y:auto" class="lgfm" id="reginfo_a">
			        <span id="activation_hidden">
				        <%if {invitecode}!=""||{config.Regstatus}==3%>
				        <label><em>邀请码:</em><input name="invitecode" type="text" id="invitecode" size="20" class="txt" maxlength="7"<%if {invitecode}!=""%> value="{invitecode}" readonly="readonly"<%/if%> /> *</label>
				        <%/if%>
				        <label><em>用户名:</em><input type="text" class="txt" tabindex="1"  value="" maxlength="20" size="25" autocomplete="off" name="{config.antispamregisterusername}" id="username" onkeyup="checkusername(this.value);"/> *</label>
				        <label><em>密码:</em><input type="password" class="txt" tabindex="1"  id="password" size="25" name="password" onblur="return checkpasswd(this);"/> *</label>	
				        <label id="passwdpower" style="display: none;"><em>密码强度</em><strong id="showmsg"></strong></label>
				        <label><em>确认密码:</em><input type="password" class="txt" value="" tabindex="1"  id="password2" size="25" name="password2" onblur="checkdoublepassword(this.form)"/> *</label>
				        <label><em>Email:</em><input type="text" class="txt" tabindex="1"  id="email" size="25" autocomplete="off" name="{config.antispamregisteremail}" onblur="checkemail(this.value)"/> *</label>
				        <%if {config.Realnamesystem}==1%>
				        <label><em>真实姓名:</em><input name="realname" type="text" id="realname" size="10" class="txt" /> *</label>
				        <label><em>身份证:</em><input name="idcard" type="text" id="idcard" size="20" class="txt" /> *</label>
				        <label><em>移动电话:</em><input name="mobile" type="text" id="mobile" size="20" class="txt" /> *</label>
				        <label><em>固定电话:</em><input name="phone" type="text" id="phone" size="20" class="txt" /> *</label>
				        <%/if%>
			        </span>
			        <%if {isseccode}%>
			        <div class="regsec">
				        <label style="display: inline;"><em>验证: </em><span style="position: relative;">
		        <%template _vcode%>
	        </span></label>
			        </div>
			        <%/if%>
		        </div>
		        <div class="lgf">
			        <h4>已有帐号？
				        <%if {infloat}==1%>
				        <a onclick="hideWindow('register');showWindow('login', this.href);" href="{rooturl}login.aspx" class="xg2">现在登录</a>
				        <%else%>
				        <a href="{rooturl}login.aspx" title="现在登录" class="xg2">现在登录</a>
				        <%/if%>
			        </h4>
		        </div>
	        </div>
	        <p class="fsb pns cl">
		        <span id="reginfo_b_btn">
		        <button tabindex="5" value="true" name="regsubmit" type="submit" id="registerformsubmit" class="pn" <%if {config.rules}==1%>onclick="return checkagreed();" <%/if%>><span>创建用户</span></button>
		        <%if {config.rules}==1%>
		        <input type="checkbox" id="agree" value="true" name="agree" class="checkbox" style="margin-left:5px;"/><label for="agreebbrule">同意<a onclick="javascript:$('bbrule').style.display='';$('bbreg').style.display='none'" href="javascript:;">网站服务条款</a></label>
			        <script type="text/javascript" reload="1">
			            function checkagreed() {
			                $('returnregmessage').className = ''; 
						        if ($('agree').checked == true) {
							        return true;
						        }
						        else {
						            $('returnregmessage').innerHTML = "请确认《网络服务条款》";
						            $('returnregmessage').className = 'onerror';
							        return false;
						        }
				        }
			        </script>
		        <%/if%>
		        </span>
	        </p>
	    </form>
        </div>
        </div>
        </div>
        <script type="text/javascript">
	        var PasswordStrength ={
		        Level : ["极佳","一般","较弱","太短"],
		        LevelValue : [15,10,5,0],//强度值
		        Factor : [1,2,5],//字符加数,分别为字母，数字，其它
		        KindFactor : [0,0,10,20],//密码含几种组成的加数 
		        Regex : [/[a-zA-Z]/g,/\d/g,/[^a-zA-Z0-9]/g] //字符正则数字正则其它正则
		        }
		
	        PasswordStrength.StrengthValue = function(pwd)
	        {
		        var strengthValue = 0;
		        var ComposedKind = 0;
		        for(var i = 0 ; i < this.Regex.length;i++)
		        {
			        var chars = pwd.match(this.Regex[i]);
			        if(chars != null)
			        {
				        strengthValue += chars.length * this.Factor[i];
				        ComposedKind ++;
			        }
		        }
		        strengthValue += this.KindFactor[ComposedKind];
		        return strengthValue;
	        } 

	        PasswordStrength.StrengthLevel = function(pwd)
	        {
		        var value = this.StrengthValue(pwd);
		        for(var i = 0 ; i < this.LevelValue.length ; i ++)
		        {
			        if(value >= this.LevelValue[i] )
				        return this.Level[i];
		        }
	        }

	        function checkpasswd(o)
	        {
		        var pshowmsg = '密码不得少于6个字符';
		        if(o.value.length<6)  {
		            $("returnregmessage").innerHTML = pshowmsg;
		            $("returnregmessage").className = 'onerror';
		        } 
		        else
		        {
		 
		           var showmsg=PasswordStrength.StrengthLevel(o.value);
		           switch(showmsg) {
		               case "太短": showmsg += " <img src='" + forumpath + "images/level/1.gif' width='88' height='11' />"; break;
		               case "较弱": showmsg += " <img src='" + forumpath + "images/level/2.gif' width='88' height='11' />"; break;
		               case "一般": showmsg += " <img src='" + forumpath + "images/level/3.gif' width='88' height='11' />"; break;
		               case "极佳": showmsg += " <img src='" + forumpath + "images/level/4.gif' width='88' height='11' />"; break;
		           }
		           $('passwdpower').style.display='';
		           $('showmsg').innerHTML = showmsg;
		           $('returnregmessage').className = '';
		           $('returnregmessage').innerHTML = '注册';		   
		        }
		 
//		        if(pshowmsg!='' &&  pshowmsg!=null && pshowmsg!=undefined)
//		        {
//		        $('returnregmessage').innerHTML=pshowmsg;
//		        $('returnregmessage').className='onerror';
//		        }
//		        else
//		        {
//		        $('returnregmessage').className='';
//		        $('returnregmessage').innerHTML='注册';
//		        }
        
 
	        }
	        function checkemail(strMail)
	        {
		        var str;
		        if(strMail.length==0) return false; 
		        var objReg = new RegExp("[A-Za-z0-9-_]+@[A-Za-z0-9-_]+[\.][A-Za-z0-9-_]") 
		        var IsRightFmt = objReg.test(strMail) 
		        var objRegErrChar = new RegExp("[^a-z0-9-._@]","ig") 
		        var IsRightChar = (strMail.search(objRegErrChar)==-1) 
		        var IsRightLength = strMail.length <= 60 
		        var IsRightPos = (strMail.indexOf("@",0) != 0 && strMail.indexOf(".",0) != 0 && strMail.lastIndexOf("@")+1 != strMail.length && strMail.lastIndexOf(".")+1 != strMail.length) 
		        var IsNoDupChar = (strMail.indexOf("@",0) == strMail.lastIndexOf("@"))
		        if (!(IsRightFmt && IsRightChar && IsRightLength && IsRightPos && IsNoDupChar))
                {
		         str="E-mail 地址无效，请提供真实Email，以便找回密码和论坛通知所用。";
		         }
	            if(str!='' &&  str!=null && str!=undefined)
		        {
		        $('returnregmessage').innerHTML=str;
		        $('returnregmessage').className='onerror';
		        }
		        else
		        {
		        $('returnregmessage').className='';
		        $('returnregmessage').innerHTML='注册';
		        }
	        }
	        function htmlEncode(source, display, tabs)
	        {
		        function special(source)
		        {
			        var result = '';
			        for (var i = 0; i < source.length; i++)
			        {
				        var c = source.charAt(i);
				        if (c < ' ' || c > '~')
				        {
					        c = '&#' + c.charCodeAt() + ';';
				        }
				        result += c;
			        }
			        return result;
		        }
		
		        function format(source)
		        {
			        // Use only integer part of tabs, and default to 4
			        tabs = (tabs >= 0) ? Math.floor(tabs) : 4;
			
			        // split along line breaks
			        var lines = source.split(/\r\n|\r|\n/);
			
			        // expand tabs
			        for (var i = 0; i < lines.length; i++)
			        {
				        var line = lines[i];
				        var newLine = '';
				        for (var p = 0; p < line.length; p++)
				        {
					        var c = line.charAt(p);
					        if (c === '\t')
					        {
						        var spaces = tabs - (newLine.length % tabs);
						        for (var s = 0; s < spaces; s++)
						        {
							        newLine += ' ';
						        }
					        }
					        else
					        {
						        newLine += c;
					        }
				        }
				        // If a line starts or ends with a space, it evaporates in html
				        // unless it's an nbsp.
				        newLine = newLine.replace(/(^ )|( $)/g, '&nbsp;');
				        lines[i] = newLine;
			        }
			
			        // re-join lines
			        var result = lines.join('<br />');
			
			        // break up contiguous blocks of spaces with non-breaking spaces
			        result = result.replace(/  /g, ' &nbsp;');
			
			        // tada!
			        return result;
		        }

		        var result = source;
		
		        // ampersands (&)
		        result = result.replace(/\&/g,'&amp;');

		        // less-thans (<)
		        result = result.replace(/\</g,'&lt;');

		        // greater-thans (>)
		        result = result.replace(/\>/g,'&gt;');
		
		        if (display)
		        {
			        // format for display
			        result = format(result);
		        }
		        else
		        {
			        // Replace quotes if it isn't for display,
			        // since it's probably going in an html attribute.
			        result = result.replace(new RegExp('"','g'), '&quot;');
		        }

		        // special characters
		        result = special(result);
		
		        // tada!
		        return result;
	        }

	        var profile_username_toolong = '您的用户名超过 20 个字符，请输入一个较短的用户名。';
	        var profile_username_tooshort = '您输入的用户名小于3个字符, 请输入一个较长的用户名。';
	        var profile_username_pass = "<img src='{imagedir}/check_right.gif'/>";

	        function checkusername(username)
	        {
		        var unlen = username.replace(/[^\x00-\xff]/g, "**").length;

		        if(unlen < 3 || unlen > 20) {
			        $("returnregmessage").innerHTML =(unlen < 3 ? profile_username_tooshort : profile_username_toolong);
			        $('returnregmessage').className = 'onerror';
			        return;
		        }
		        ajaxRead("{rooturl}tools/ajax.aspx?t=checkusername&username=" + escape(username), "showcheckresult(obj,'" + escape(username) + "');");
	        }

	        function showcheckresult(obj, username)
	        {
		        var res = obj.getElementsByTagName('result');
		        var result = "";
		        if (res[0] != null && res[0] != undefined)
		        {
			        if (res[0].childNodes.length > 1) {
				        result = res[0].childNodes[1].nodeValue;
			        } else {
				        result = res[0].firstChild.nodeValue;    		
			        }
		        }
		        if (result == "1")
		        {
		            var tips="对不起，您输入的用户名 \"" + htmlEncode(unescape(username), true, 4) + "\" 已经被他人使用或被禁用。";
			        $('returnregmessage').innerHTML=tips;
			        $('returnregmessage').className='onerror';
		        }
		        else
		        {
			        $('returnregmessage').className='';
			         $('returnregmessage').innerHTML='注册';
		        }
	        }

	        function checkdoublepassword(theform)
	        {
	          var pw1 = theform.password.value;
	          var pw2 = theform.password2.value;
	          if(pw1=='' &&  pw2=='')
	          {
	          return;
	          }
	          var str;
	  
		         if(pw1!=pw2)
		         {
		          str ="两次输入的密码不一致";
		         }
		          if(str!='' &&  str!=null && str!=undefined)
		          {
		          $('returnregmessage').innerHTML=str;
		          $('returnregmessage').className='onerror';
		          }
		          else
		          {
		          $('returnregmessage').className='';
		          $('returnregmessage').innerHTML='注册';
		          }
	        }
	    </script>
	    <script type="text/javascript"  src="{jsdir}/ajax.js"></script>
    <%else%>
        <%if {infloat}==1%>
        	<h3 class="flb"><em>出现了{page_err}个错误</em><span><a href="javascript:;" class="flbc" onclick="hideWindow('register')" title="关闭">关闭</a></span></h3>
            <div class="c cl" id="errormsg">
		        <div class="msg_inner error_msg">
		            <p style="margin-bottom:16px;line-height:60px;">{msgbox_text}</p>
		        </div>
	        </div>
        <%else%>
            <%template _errmsgbox%>
        <%/if%>
    <%/if%>
<%else%>
    <%if {createuser}!=""%>
        <%if {infloat}==1%>
	        <%if page_err==0%>	
	            <script type="text/javascript">
	                $('form2').style.display='none';
	                $('returnregmessage').className='';
	            </script>
	            <div class="msgbox cl" id="succeemessage">
		            <div class="msg_inner">
		            <p style="margin-bottom:16px;">{msgbox_text}</p>
		            <%if {msgbox_url}!=""%>
		            <p><a href="javascript:;" onclick="location.reload()" class="xg2">如果长时间没有响应请点击此处</a></p>
		            <script type="text/javascript">setTimeout('location.reload()', 3000);</script>
		            <%/if%>
		            </div>
	            </div>
	            <script>
	                $('succeedmessage').style.display='';
	                $('succeedmessage').innerHTML=$('succeemessage').innerHTML;
	                $('returnregmessage').innerHTML='注册';
	            </script>	
	        <%else%>
	            <p>{msgbox_text}</p>
	        <%/if%>
	    <%else%>
		    <%if page_err==0%>
		        <%template _msgbox%>
		    <%else%>
		        <%template _errmsgbox%>
		    <%/if%>
	    <%/if%>
    <%/if%>
<%/if%>
<%/if%>
<%template _copyright%>
<%template _footer%>